{% block crucible_process_metrics_block %}
<!-- BEGIN /crucible>?process_metrics=true block -->
{% if print_debug == 'True' %}
<code> DEBUG </code> :: /crucible crucible_process_metrics_block</br>
{% endif %}

{% if display_message %}
<code> ERROR </code></br>
<code> message </code>: {{ display_message }}<br>
{% endif %}

<script>
function validate_to_process_submission()
{
    var source = document.forms["process_metrics"]["source"];
    var training_data_json = document.forms["process_metrics"]["training_data_json"];
    if (source.value == "training_data") and (training_data_json.value == "")
    {
        window.alert("Please enter the training_data json file");
        training_data_json.focus();
        return false;
    }
    if (source.value == "training_data") and (add_to_panaroma.value == "true")
    {
        window.alert("You cannot add anomalies from training data to Panorama");
        add_to_panaroma.focus();
        return false;
    }
    return true;
}</script>

<div class="navbar-header" role="navigation">
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>
		<ul class="nav nav-tabs" role="view_tablist" id="view">
		  <li><a href="/crucible"><span class="logo"><span class="sky">Crucible</span> <span class="re">jobs</span></span></span></a></li>
		  <li class="active"><a href="?process_metrics=true"><span class="logo"><span class="sky">Process</span> <span class="re">metrics</span></span></span></a></li>
		  <li><a href="?crucible_job"><span class="logo"><span class="sky">Crucible</span> <span class="re">job</span></span></span></a></li>
		</ul>
		<div class="tab-content">
	  	<div class="tab-pane active" id="view">
	<br>
  <div class="navbar-header" role="navigation">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
  </div>

  		<div class="col-md-12">
<!--  		<div class="container"> -->
    {% if not crucible_enabled %}
    <h4><span class="logo"><span class="sky">Crucible ::</span> <span class="re">NOT ENABLED ::</span></span> jobs will not be processed</h4>
    {% endif %}

  		  <h4><span class="logo"><span class="sky">Process ::</span> <span class="re">metrics</span></span></span></h4>

  {% if job_submitted %}
	  <div class="alert alert-success">
	    <strong>Submitted job</strong> :: job id {{ crucible_job_id }}<br>
      With metrics to process:<br>
    {% for metric_submitted_to_process in metrics_submitted_to_process %}
      {{ metric_submitted_to_process }}<br>
    {% endfor %}
	  </div>
  {% endif %}

  {% if job_submitted %}
        <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#process_options">Show process options</button>
        <div id="process_options" class="collapse">
  {% endif %}
        <form name="process_metrics" action="crucible" onsubmit="return validate_to_process_submission()">
  		  <table class="table table-hover">
  		    <thead>
  		      <tr>
  		        <th>Option</th>
  		        <th>value</th>
  		      </tr>
  		    </thead>
  		    <tbody>
  		      <tr>
  		        <td>Process metrics</td>
  		        <td><select name="process_metrics">
                <option value="true">true</option>
              </select></td>
  		      </tr>
  		      <tr>
  		        <td>metrics</td>
  		        <td><input type="text" name="metrics" value="" /> a list of comma separated metric names e.g server1.cpu.total,server2.cpu.user</td>
  		      </tr>
  		      <tr>
  		        <td>namespaces</td>
  		        <td><input type="text" name="namespaces" value="" /> a list of comma separated metric namespaces with MySQL like wildcards e.g server1.cpu%,server2.cpu.%</td>
  		      </tr>
  		      <tr>
              <td>from_timestamp</td>
              <td><input type="number" name="from_timestamp" value="" /> [required] unix timestamp</td>
  		      </tr>
  		      <tr>
              <td>until_timestamp</td>
              <td><input type="number" name="until_timestamp" value="" /> [required] unix timestamp</td>
  		      </tr>
<!--        # @added 20200422 - Feature #3500: webapp - crucible_process_metrics
            #                   Feature #1448: Crucible web UI
            # In order for metrics to be analysed in Crucible like the Analyzer
            # or Mirage analysis, the time series data needs to be padded
-->
  		      <tr>
                <td>pad_timeseries</td>
  		        <td><select name="pad_timeseries">
                <option value="auto">auto</option>
                <option value="0">none</option>
                <option value="86400">1 day</option>
                <option value="604800">7 days</option>
              </select><br>
              The amount with which to pad the time series data with so that Crucible does not start analysis<br>
              at the <code>from_timestamp</code>, with no reference data.  Default is <code>auto</code> generally this<br>
              is acceptable.  The data points in the prefix period will not be analysed individually, they are<br>
              only used in the population so that the first data points from the <code>from_timestamp</code> can be compared<br>
              against data other than themselves.<br>
              This makes the jobs submitted to Crucible have results more like the real Analyzer/Mirage analysis rather then<br>
              default Crucible methodology.</td>
  		      </tr>
  		      <tr>
  		        <td>data source</td>
  		        <td><select name="data_source">
                <option value="graphite">graphite</option>
<!--
# Graphite is the only option currently
                <option value="redis">redis</option>
-->
<!--          # @added 20200607 - Feature #3630: webapp - crucible_process_training_data -->
                <option value="training_data">training_data</option>
              </select></td>
  		      </tr>
  		      <tr>
  		        <td>training_data_json</td>
  		        <td><input type="text" name="training_data_json" value="" /> the full path to training_data or saved trianing data json, if data_source is set to training_data</td>
  		      </tr>
  		      <tr>
                <td>alert interval</td>
                <td><input type="number" name="alert_interval" value="" /> How many seconds to allow between anomalies, ala <code>EXPIRATION_TIME</code></td>
  		      </tr>
  		      <tr>
              <td>add_to_panorama</td>
  		        <td><select name="add_to_panorama">
                <option value="false">false</option>
                <option value="true">true</option>
              </select> Whether to send Skyline <code>CONSENSUS</code> anomalies to Panorama, defaults to <code>false</code> as you probably want to validate first</td>
  		      </tr>
<!--        # @added 20200817 - Feature #3682: SNAB - webapp - crucible_process - run_algorithms
            # Allow the user to pass algorithms to run -->
  		      <tr>
              <td>run_algorithms</td>
  		        <td><input type="text" name="run_algorithms" value="true" /> a list of comma separated algorithms to run e.g, the default when set to true<br>
<code>histogram_bins,first_hour_average,stddev_from_average,grubbs,ks_test,mean_subtraction_cumulation,median_absolute_deviation,stddev_from_moving_average,least_squares</code><br>
or <code>detect_drop_off_cliff</code> or <code>ks_test,detect_drop_off_cliff</code>, etc</td>
  		      </tr>
  		    </tbody>
  		  </table>
        <br>
        <input type="submit" value="Process metrics">
      </form>
      </div>

    </div> <!-- END div class="col-md-12" -->

	</div>
	</div>
	</div>

<!-- END /crucible?process_metrics=true block -->
{% endblock %}
